<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head lang="en">
    <meta charset="UTF-8">
    <title>预约-排班</title>
    <base th:href="@{http://localhost:9090/}"/>
    <link th:href="@{/bs/css/bootstrap.css}" rel="stylesheet">
    <script th:src="@{/js/jquery-3.2.1.min.js}" type="text/javascript"></script>
    <script th:src="@{/bs/js/bootstrap.js}" type="text/javascript"></script>
    <style type="text/css">
        #body{
            width: 1200px;
            margin: 20px auto;
        }
        h1{
            width: 200px;
            margin: 0 auto;
            color: red;
        }
    </style>
    <script type="text/javascript">
        $(function (){
            var workforcesDoctor = "[[${workforcesDoctor}]]";
            var workforcesDepartment = "[[${workforcesDepartment}]]";
            $.ajax({
                url: "/dmy/getWordByKidAndDid",
                type: "GET",
                data: {"workforcesDepartment" : workforcesDepartment ,"workforcesDoctor" : workforcesDoctor} ,
                dataType: "json",
                success:function(workForcesList){
                    if (workForcesList!=null){
                        show(workForcesList);
                    }else {
                        alert("暂时没有值班医生!")
                    }

                },
                error: function (workForcesList){
                    alert("查询医生失败!")
                }
            })
        })
        function show(workForcesList){
            var workStr = "";
            for (var i = 0; i < workForcesList.length; i++) {
                workStr += '<div style="border: 1px solid #93DAFF; width:200px ; height:100px ; background-color: #93DAFF ; display: inline-block ; padding: 15px ">'
                    + '<p>时间:' + time(workForcesList[i].workforcesTime) + '</p>'
                    + '<p>余号:' + workForcesList[i].registration + '</p>'
                    + '<a id="id" onclick="aa(' + time(workForcesList[i].workforcesTime) + ')" >预约</a>'
                    + '</div>';
            }

            $("#body").append(workStr);
        }
        function time(workTime){
            var date = new Date(workTime)
            return date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
        }
        function aa(time){
            var url = '/dmy/toaddBook?workforcesTime='+ time;
            window.open(url,'_self')
        }
    </script>
</head>
<body>
    <div id="body">
        <h1>请选择时间</h1>
    </div>
</body>
</html>